<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <div v-if="crud.props.searchToggle">
        <el-date-picker
          v-model="value2"
          type="month"
          format="yyyyMM"
          placeholder="选择月"
        />
        <rrOperation :crud="crud" />
        <div hidden>{{ linstensing(this.value2) }}</div>
      </div>
      <!--表格渲染-->
      <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
        <el-table-column type="selection" width="55" />
        <el-table-column prop="aab034" label="统筹区" />
        <el-table-column prop="akb020" label="服务机构编号" />
        <el-table-column prop="akb021" label="服务机构名称" />
        <el-table-column prop="aae002" label="费款所属期" />
        <el-table-column prop="cjt100" label="参保类型" />
        <el-table-column prop="akb062" label="住院人次" />
        <el-table-column prop="ckb152" label="住院个人现金支出" />
        <el-table-column prop="ckb151" label="住院帐户支出金额" />
        <el-table-column prop="ckb153" label="住院公务员补助支出" />
        <el-table-column prop="akb068" label="统筹支付金额" />
        <el-table-column prop="zkb060" label="救助金支出" />
        <el-table-column prop="tsryzf" label="特殊人员支付" />
        <el-table-column prop="ckb156" label="住院保健对象补贴支出" />
        <el-table-column prop="ckb208" label="住院高知支付" />
        <el-table-column prop="yjbjdx" label="一级保健对象支付" />
        <el-table-column prop="akb064" label="住院费用" />
        <el-table-column prop="ckb161" label="住院实际偿付总额" />
        <el-table-column prop="ckb169" label="住院预留风险基金总额" />
        <el-table-column prop="insuNo" label="拨付机构代码" />
        <el-table-column prop="insuName" label="拨付机构名称" />
        <el-table-column fixed="right" label="操作" width="150px" align="center">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="primary"
              @click="toOpen(scope.row)"
            >预 览</el-button>
          </template>
        </el-table-column>
      </el-table>
      <!--分页组件-->
      <pagination />
      <!-- 打印拨付单 -->
      <printView ref="printView" />
    </div>
  </div>
</template>

<script>
import printView from '../kb03/printView'
import crudPggs from '@/api/business/pggs'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'
import moment from 'moment'

const defaultForm = { aae002: null }
export default {
  name: 'Pggs',
  components: { pagination, crudOperation, rrOperation, udOperation, printView },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  dicts: ['ccs'],
  cruds() {
    return CRUD({ title: '照护拨付单', url: 'api/pay/queryKb03', idField: 'id', sort: 'aae002,desc', crudMethod: { ...crudPggs }})
  },
  data() {
    return {
      value2: '',
      permission: {
        add: ['admin', 'pggs:add'],
        edit: ['admin', 'pggs:edit'],
        del: ['admin', 'pggs:del']
      },
      rules: {
        bisGsglQymc: [
          { required: true, message: '企业名称不能为空', trigger: 'blur' }
        ],
        bisGsglTyshxydm: [
          { required: true, message: '统一社会信用代码不能为空', trigger: 'blur' }
        ],
        bisGsglLxr: [
          { required: true, message: '联系人不能为空', trigger: 'blur' }
        ],
        bisGsglLxrdh: [
          { required: true, message: '联系人电话不能为空', trigger: 'blur' }
        ],
        bisGsglSsqx: [
          { required: true, message: '所属区县不能为空', trigger: 'blur' }
        ],
        bisGsglZcdz: [
          { required: true, message: '注册地址不能为空', trigger: 'blur' }
        ]
      },
      queryTypeOptions: [
        { key: 'bisGsglQymc', display_name: '企业名称' },
        { key: 'bisGsglTyshxydm', display_name: '统一社会信用代码' },
        { key: 'bisGsglLxr', display_name: '联系人' },
        { key: 'bisGsglLxrdh', display_name: '联系人电话' },
        { key: 'bisGsglSsqx', display_name: '所属区县' },
        { key: 'bisGsglZcdz', display_name: '注册地址' }
      ]
    }
  },
  methods: {
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      return true
    },
    linstensing(d) {
      // query.aae002
      const date1 = moment(d).format('YYYYMM')
      this.query.aae002 = date1
      return date1
    },
    toOpen(row) {
      console.log(row)
      this.$refs.printView.printViewDialog = true
      this.$refs.printView.dataValue = row
      this.$refs.printView.tempAae002 = moment(row.aae002).format('YYYY年MM月')
      this.$refs.printView.tempCjt100 = row.cjt100
    }
  }
}
</script>

<style scoped>

</style>
